package com.ziyun.pop.web.modules.order.controller;

import com.ziyun.pop.common.e.order.OnCreditEnum;
import com.ziyun.pop.common.utils.UserUtils;
import com.ziyun.pop.modules.order.dto.MonthlyOrderPayDto;
import com.ziyun.pop.modules.order.service.ErpOrderService;
import io.renren.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 月结订单
 * @author gaosheng
 * @date 2018-09-26 11:04
 */
@RestController
@RequestMapping("order/monthlyorder")
public class MonthlyOrderController {

    @Autowired
    private ErpOrderService erpOrderService;

    /**
     * 月结订单列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        params.put("supplierId", UserUtils.getCurentUser().getSellerId());
        params.put("onCredit", OnCreditEnum.ON_CREDIT.toInt());
        return erpOrderService.queryPageMonthlyOrderList(params);
    }

    /**
     * 确认收款页面
     * @param orderNos
     * @return
     */
    @RequestMapping("/collectMoneyPage")
    public R collectMoneyPage(@RequestBody String[] orderNos){
        return erpOrderService.collectMoneyPage(orderNos);
    }

    /**
     * 月结订单收款
     * @return
     */
    @RequestMapping("/orderPay")
    public R orderPay(@RequestBody MonthlyOrderPayDto monthlyOrderPayDto){
        return erpOrderService.monthlyOrderPay(monthlyOrderPayDto);
    }

}
